<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>DynamicBuffer</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Boost.Beast">
<link rel="up" href="../concepts.html" title="Concepts">
<link rel="prev" href="BufferSequence.html" title="BufferSequence">
<link rel="next" href="Fields.html" title="Fields">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="BufferSequence.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Fields.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="beast.concepts.DynamicBuffer"></a><a class="link" href="DynamicBuffer.html" title="DynamicBuffer">DynamicBuffer</a>
</h3></div></div></div>
<p>
        A dynamic buffer encapsulates memory storage that may be automatically resized
        as required, where the memory is divided into an input sequence followed
        by an output sequence. These memory regions are internal to the dynamic buffer,
        but direct access to the elements is provided to permit them to be efficiently
        used with I/O operations, such as the send or receive operations of a socket.
        Data written to the output sequence of a dynamic buffer object is appended
        to the input sequence of the same object.
      </p>
<p>
        The interface to this concept is intended to permit the following implementation
        strategies:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            A single contiguous octet array, which is reallocated as necessary to
            accommodate changes in the size of the octet sequence. This is the implementation
            approach currently offered by <a class="link" href="../ref/boost__beast__flat_buffer.html" title="flat_buffer"><code class="computeroutput"><span class="identifier">flat_buffer</span></code></a>.
          </li>
<li class="listitem">
            A sequence of one or more octet arrays, where each array is of the same
            size. Additional octet array objects are appended to the sequence to
            accommodate changes in the size of the octet sequence.
          </li>
<li class="listitem">
            A sequence of one or more octet arrays of varying sizes. Additional octet
            array objects are appended to the sequence to accommodate changes in
            the size of the character sequence. This is the implementation approach
            currently offered by <a class="link" href="../ref/boost__beast__multi_buffer.html" title="multi_buffer"><code class="computeroutput"><span class="identifier">multi_buffer</span></code></a>.
          </li>
</ul></div>
<h5>
<a name="beast.concepts.DynamicBuffer.h0"></a>
        <span class="phrase"><a name="beast.concepts.DynamicBuffer.associated_types"></a></span><a class="link" href="DynamicBuffer.html#beast.concepts.DynamicBuffer.associated_types">Associated
        Types</a>
      </h5>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">is_dynamic_buffer</span></code>
          </li>
<li class="listitem">
            <a href="../../../../../../doc/html/boost_asio/reference/ConstBufferSequence.html" target="_top"><span class="bold"><strong>ConstBufferSequence</strong></span></a>
          </li>
<li class="listitem">
            <a href="../../../../../../doc/html/boost_asio/reference/MutableBufferSequence.html" target="_top"><span class="bold"><strong>MutableBufferSequence</strong></span></a>
          </li>
</ul></div>
<h5>
<a name="beast.concepts.DynamicBuffer.h1"></a>
        <span class="phrase"><a name="beast.concepts.DynamicBuffer.requirements"></a></span><a class="link" href="DynamicBuffer.html#beast.concepts.DynamicBuffer.requirements">Requirements</a>
      </h5>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            <code class="computeroutput"><span class="identifier">D</span></code> denotes a dynamic buffer
            class.
          </li>
<li class="listitem">
            <code class="computeroutput"><span class="identifier">a</span></code> denotes a value of
            type <code class="computeroutput"><span class="identifier">D</span></code>.
          </li>
<li class="listitem">
            <code class="computeroutput"><span class="identifier">c</span></code> denotes a (possibly
            const) value of type <code class="computeroutput"><span class="identifier">D</span></code>.
          </li>
<li class="listitem">
            <code class="computeroutput"><span class="identifier">n</span></code> denotes a value of
            type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
          </li>
<li class="listitem">
            <code class="computeroutput"><span class="identifier">T</span></code> denotes a type meeting
            the requirements for <a href="../../../../../../doc/html/boost_asio/reference/ConstBufferSequence.html" target="_top"><span class="bold"><strong>ConstBufferSequence</strong></span></a>.
          </li>
<li class="listitem">
            <code class="computeroutput"><span class="identifier">U</span></code> denotes a type meeting
            the requirements for <a href="../../../../../../doc/html/boost_asio/reference/MutableBufferSequence.html" target="_top"><span class="bold"><strong>MutableBufferSequence</strong></span></a>.
          </li>
</ul></div>
<div class="table">
<a name="beast.concepts.DynamicBuffer.valid_expressions"></a><p class="title"><b>Table&#160;1.31.&#160;Valid expressions</b></p>
<div class="table-contents"><table class="table" summary="Valid expressions">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Expression
                </p>
              </th>
<th>
                <p>
                  Type
                </p>
              </th>
<th>
                <p>
                  Semantics, Pre/Post-conditions
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">D</span><span class="special">::</span><span class="identifier">const_buffers_type</span></code>
                </p>
              </td>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">T</span></code>
                </p>
              </td>
<td>
                <p>
                  This type represents the memory associated with the input sequence.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">D</span><span class="special">::</span><span class="identifier">mutable_buffers_type</span></code>
                </p>
              </td>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">U</span></code>
                </p>
              </td>
<td>
                <p>
                  This type represents the memory associated with the output sequence.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>
                </p>
              </td>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>
                </p>
              </td>
<td>
                <p>
                  Returns the size, in bytes, of the input sequence.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">max_size</span><span class="special">()</span></code>
                </p>
              </td>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>
                </p>
              </td>
<td>
                <p>
                  Returns the permitted maximum of the sum of the sizes of the input
                  sequence and output sequence.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">capacity</span><span class="special">()</span></code>
                </p>
              </td>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>
                </p>
              </td>
<td>
                <p>
                  Returns the maximum sum of the sizes of the input sequence and
                  output sequence that the dynamic buffer can hold without requiring
                  reallocation.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">data</span><span class="special">()</span></code>
                </p>
              </td>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">D</span><span class="special">::</span><span class="identifier">const_buffers_type</span></code>
                </p>
              </td>
<td>
                <p>
                  Returns a constant buffer sequence u that represents the memory
                  associated with the input sequence, and where <code class="computeroutput"><span class="identifier">buffer_size</span><span class="special">(</span><span class="identifier">u</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">size</span><span class="special">()</span></code>.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">prepare</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>
                </p>
              </td>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">D</span><span class="special">::</span><span class="identifier">mutable_buffers_type</span></code>
                </p>
              </td>
<td>
                <p>
                  Returns a mutable buffer sequence u representing the output sequence,
                  and where <code class="computeroutput"><span class="identifier">buffer_size</span><span class="special">(</span><span class="identifier">u</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">n</span></code>. The dynamic buffer reallocates
                  memory as required. All constant or mutable buffer sequences previously
                  obtained using <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">prepare</span><span class="special">()</span></code> are invalidated.
                </p>
                <p>
                  Throws: <code class="computeroutput"><span class="identifier">length_error</span></code>
                  if <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span>
                  <span class="special">+</span> <span class="identifier">n</span></code>
                  exceeds <code class="computeroutput"><span class="identifier">max_size</span><span class="special">()</span></code>.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">commit</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>
                </p>
              </td>
<td>
              </td>
<td>
                <p>
                  Appends <code class="computeroutput"><span class="identifier">n</span></code> bytes
                  from the start of the output sequence to the end of the input sequence.
                  The remainder of the output sequence is discarded. If <code class="computeroutput"><span class="identifier">n</span></code> is greater than the size of
                  the output sequence, the entire output sequence is appended to
                  the input sequence. All constant or mutable buffer sequences previously
                  obtained using <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">prepare</span><span class="special">()</span></code> are invalidated.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">consume</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>
                </p>
              </td>
<td>
              </td>
<td>
                <p>
                  Removes <code class="computeroutput"><span class="identifier">n</span></code> bytes
                  from beginning of the input sequence. If <code class="computeroutput"><span class="identifier">n</span></code>
                  is greater than the size of the input sequence, the entire input
                  sequence is removed. All constant or mutable buffer sequences previously
                  obtained using <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">prepare</span><span class="special">()</span></code> are invalidated.
                </p>
              </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><h5>
<a name="beast.concepts.DynamicBuffer.h2"></a>
        <span class="phrase"><a name="beast.concepts.DynamicBuffer.models"></a></span><a class="link" href="DynamicBuffer.html#beast.concepts.DynamicBuffer.models">Models</a>
      </h5>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            <a class="link" href="../ref/boost__beast__basic_flat_buffer.html" title="basic_flat_buffer"><code class="computeroutput"><span class="identifier">basic_flat_buffer</span></code></a>
          </li>
<li class="listitem">
            <a class="link" href="../ref/boost__beast__basic_multi_buffer.html" title="basic_multi_buffer"><code class="computeroutput"><span class="identifier">basic_multi_buffer</span></code></a>
          </li>
<li class="listitem">
            <a class="link" href="../ref/boost__beast__flat_buffer.html" title="flat_buffer"><code class="computeroutput"><span class="identifier">flat_buffer</span></code></a>
          </li>
<li class="listitem">
            <a class="link" href="../ref/boost__beast__flat_static_buffer.html" title="flat_static_buffer"><code class="computeroutput"><span class="identifier">flat_static_buffer</span></code></a>
          </li>
<li class="listitem">
            <a class="link" href="../ref/boost__beast__flat_static_buffer_base.html" title="flat_static_buffer_base"><code class="computeroutput"><span class="identifier">flat_static_buffer_base</span></code></a>
          </li>
<li class="listitem">
            <a class="link" href="../ref/boost__beast__static_buffer.html" title="static_buffer"><code class="computeroutput"><span class="identifier">static_buffer</span></code></a>
          </li>
<li class="listitem">
            <a class="link" href="../ref/boost__beast__static_buffer_base.html" title="static_buffer_base"><code class="computeroutput"><span class="identifier">static_buffer_base</span></code></a>
          </li>
<li class="listitem">
            <a class="link" href="../ref/boost__beast__multi_buffer.html" title="multi_buffer"><code class="computeroutput"><span class="identifier">multi_buffer</span></code></a>
          </li>
</ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2016, 2017 Vinnie Falco<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="BufferSequence.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Fields.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
